//
//  UIImage+YKExtension.m
//  baisi
//
//  Created by 吴高烽 on 2016/10/27.
//  Copyright © 2016年 吴高烽. All rights reserved.
//

#import "UIImage+YKExtension.h"

@implementation UIImage (YKExtension)
-(UIImage *)circleImage{
//    NO 代表透明
    UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0);
//    获取图形上下文
    CGContextRef ctx = UIGraphicsGetCurrentContext() ;
//    添加一个圆
    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
    CGContextAddEllipseInRect(ctx, rect);
//    裁剪图片
    CGContextClip(ctx);
//    将图片画到图形上下文中
    [self drawInRect:rect];
    UIImage *image  = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return  image ;
}
@end
